package com.neuedu.helloworld.controller;

import com.neuedu.helloworld.entity.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.*;

@RestController
public class JsonController {


    @RequestMapping("/returnStr")
    String returnStr() {

        return "currentTime " + System.currentTimeMillis();
    }


    @RequestMapping("/returnUser")
    User returnUser() {

//        return new User(100, "张飞");
        return new User(100, "张飞",new Date());
    }


    @RequestMapping("/returnUserList")
    List<User> returnUserList() {

        List list = new ArrayList();

        for (int i = 0; i < 10; i++) {

            list.add(new User(100 + i, "张飞" + i));

        }

        return list;
    }


    @RequestMapping("/returnMap")
    Map returnMap() {

        Map map = new HashMap();

        map.put("id",901);
        map.put("name","刘备");

        return map;
    }


}
